<?php

use yak\layui\widgets\grid\LayuiGridView;
use yii\helpers\Url;

/* @var $this yii\web\View */
/* @var $searchModel yak\layui\search\DictionarySearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = '字典管理';
$this->params['breadcrumbs'][] = $this->title;
$this->params['link'] = Url::toRoute('index');

?>
<div class="dictionary-index">


    <script type="text/html" id="toolBar">
        <a class="layui-btn layui-btn-normal layui-btn-sm" lay-event="create">
            <i class="layui-icon layui-icon-file-b"> 新建</i>
        </a>
        <a class="layui-btn layui-btn-danger layui-btn-sm" lay-event="deleteBatch">
            <i class="layui-icon layui-icon-delete"> 批量删除</i>
        </a>
    </script>

    <script type="text/html" id="tool">
        <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">查看</a>
        <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
        <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
    </script>
	
	<div class="layui-card">
        <div class="layui-card-header yak-search-card-header">
            <?php  echo $this->render('_search', ['model' => $searchModel]); ?>
        </div>
        <div class="layui-card-body">
            <table id="dictionary-table" lay-filter="dictionary-table-filter"></table>
        </div>
    </div>

    <?=  LayuiGridView::widget([
			'searchModel' => $searchModel,
			'dataProvider' => $dataProvider,
			'tableId' => 'dictionary-table',
			'tableFilter' => 'dictionary-table-filter',
			'searchFilter' => 'dictionary-search',
			// 'sort' => 'server',
			'tableOptions' => [
				'url' => Url::toRoute(['index']),
				'toolbar' => '#toolBar',
				'page' => [
					'hash' => 'fenye'
				],
				'defaultToolbar' => [
					'filter',
					'print',
					[
						'title' => '导出Excel',
						'layEvent' => 'OUTPUT_EXCEL',
						'icon' => 'layui-icon-export',
					]
				]
			],
			'editorOptions' => [
				'url' => Url::toRoute(['update']),
                'condition' => ['sign' => ':sign'],
				'method' => 'get',
			],
			'eventOptions' => [
				'detail' => [
					'url' => Url::toRoute(['view']),
                    'condition' => ['sign' => ':sign'],
				],
				'edit' => [
					'url' => Url::toRoute(['update']),
                    'condition' => ['sign' => ':sign'],
					'openRefresh' => true
				],
				'del' => [
					'url' => Url::toRoute(['delete']),
                    'condition' => ['sign' => ':sign'],
					'message' => '确定删除该项目？'
				],
				'create' => [
					'url' => Url::toRoute(['create']),
					'openRefresh' => true
				],
				'OUTPUT_EXCEL' => [
					'url' => Url::toRoute(['output']),
					'filename' => '字典列表'
				],
				'deleteBatch' => [
					'url' => Url::toRoute(['batch-delete']),
                    'condition' => ['ids' => 'sign'],
					'message' => '确定删除？'
				]
			]
		]) ?>

</div>
